local SML = AceLibrary("SharedMedia-1.0")

local defaultAlertTypes
{
	chatWindow = false,
	scrollingCombatText = false,
	sound = "Interface\\Addons\\TargetAlert\\Sounds\\alert.mp3"
}

TargetAlert = AceLibrary("AceAddon-2.0"):new(
    "AceConsole-2.0", 
    "AceDB-2.0", 
    "AceEvent-2.0",
    "AceModuleCore-2.0",
    "AceDebug-2.0"
)

-- Expoxe AceHook and AceEvent to our modules
TargetAlert:SetModuleMixins("AceEvent-2.0", "AceDebug-2.0", "AceConsole-2.0")

TargetAlert.options = {
    name = "Target Alert",
    desc = "A framework for alerting upon target selection",
    type = "group",
    args = {}
}
function TargetAlert:Defaults()
self:RegisterDefaults("profile", {
	message = "Warning! You have a civilian selected!",
	showInChat = false,
	showOnScreen = true,
	playSound = true,
	customSoundName = "alert.mp3",
	useModuleSettings = true,
} )
end

function TargetAlert:OnInitialize()
	self:RegisterDB("TargetAlertDB", "TargetAlertDBPC")
	self:Defaults()
	self:RegisterChatCommand({"/targetalert", "/ta"}, options)
end

function TargetAlert:OnEnable()
	self:SetDebugging(true) 
    self:RegisterEvent("PLAYER_TARGET_CHANGED")
	--self:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
end

function TargetAlert:PLAYER_TARGET_CHANGED()
	for name,module in self:IterateModules() do
		if module.OnTargetChanged and type(module.OnTargetChanged) == "function" then
			module:OnTargetChanged()
        end
	end
end

-- Rather than a catch all have seperate mouseovers for monster, pvp flagged etc
--[[
function TargetAlert:UPDATE_MOUSEOVER_UNIT()
	for name,module in self:IterateModules() do
		if module.OnMouseoverUnit and type(module.OnMouseoverUnit) == "function" then
			module:OnMouseoverUnit()
        end
	end
end]]

function SendAlert(message, alertData)
	if self.db.profile.useModuleSettings then
		-- Use Module specific settings
	else
		--Use global settings
	end
	
end
